package com.ry.chat.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class ClientChannelHandler extends ChannelInboundHandlerAdapter {

    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("已经连接服务器");

//        String sb = "已经连接服务器";
//        ByteBuf byteBuf= Unpooled.buffer(sb.length());
//        byteBuf.writeBytes(sb.getBytes());
//        ctx.writeAndFlush(byteBuf);

        ctx.writeAndFlush("hello!" + ctx.channel().remoteAddress());
    }

    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("读取到消息..." + msg);
    }
}
